package com.cy.lib.widget;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

/**
 * Created by CY on 2015/8/24.
 * @title 禁止滚动ViewPager
 */
public class UnSlideViewPager extends ViewPager {

    private boolean unSlide = true;

    public UnSlideViewPager(Context context) {
        super(context);
    }

    public UnSlideViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        if (!unSlide)
            return super.onInterceptTouchEvent(ev);
        return false;
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        if (!unSlide)
            return super.onTouchEvent(ev);
        return false;
    }

    public void setUnSlide(boolean unSlide) {
        this.unSlide = unSlide;
    }
}
